package logic

import (
	"context"
	"wechat/models/mysql"

	"wechat/wechatrpc/internal/svc"
	"wechat/wechatrpc/wechatrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserShowLogic {
	return &UserShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UserShowLogic) UserShow(in *wechatrpc.UserShowRequest) (*wechatrpc.UserShowResponse, error) {
	// todo: add your logic here and delete this line

	var user mysql.User

	if err := user.FindUserById(mysql.DB, in.UserId); err != nil {
		return nil, err
	}

	return &wechatrpc.UserShowResponse{
		Mobile:     user.Mobile,
		NickName:   user.NickName,
		Address:    user.Address,
		Password:   user.Password,
		HeadImage:  user.HeadImage,
		WechatCode: user.WechatCode,
		Qq:         user.Qq,
		Email:      user.Email,
	}, nil
}
